normalize  MACRO sign, exponent, fraction
LOCAL  endZero, while1, while2, endWhile1, endWhile2
; Normalize floating point number represented by separate pieces:
;   sign: byte
;   exponent: word (bias removed)
;   fraction: doubleword (with leading 1)
          push eax             ; save EAX
          cmp  fraction, 0     ; zero fraction?
          je   endZero         ; exit if so
while1:   mov  eax, fraction   ; copy fraction
          and  eax, 0ff000000h ; non-zero leading byte?
          jz   endWhile1       ; exit if zero
          shr  fraction, 1     ; shift fraction bits right
          inc  exponent        ; subtract 1 from exponent
          jmp  while1          ; repeat
endWhile1:
while2:   mov  eax, fraction   ; copy fracton
          and  eax, 800000h    ; check bit 23
          jnz  endWhile2       ; exit if 1
          shl  fraction, 1     ; shift fraction bits left
          dec  exponent        ; subtract 1 from exponent
          jmp  while2          ; repeat
endWhile2:
endZero:
          pop  eax             ; restore EAX
          ENDM

